home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / NetBSD / docs-netbsd / Mailinglist-Archive / 1994-08.gz / 1994-08 / 000004_owner-current-u…s.berkeley.edu_Mon Aug 1 00:26:54 1994.msg < prev    next >
Text File  |  1994-10-16  |  2KB  |  41 lines

  1. To: Bill & <sommerfeld@orchard.medford.ma.us>
  2. Cc: Ken Hornstein <kenh@wrl.epi.com>, peter@alice.wonderland.org,
  3.         current-users@sun-lamp.cs.berkeley.edu
  4. Subject: Re: GET THIS BOOK :) 
  5.              <199407311856.OAA00234@orchard.medford.ma.us> 
  6. From: Greg Hudson <ghudson@MIT.EDU>
  7. Content-Length: 1648
  8. Sender: owner-current-users@sun-lamp.cs.berkeley.edu
  9.  
  10.  
  11. > (There *are* structural problems with UNIX, though, especially in
  12. > the area of the terminal driver, but that's really off-topic for
  13. > this list.  For example, see what happens to your shell when you run
  14. > a program which sets non-blocking mode on your TTY and then
  15. > exits...)
  16.  
  17. Actually, I do think that's related to this list.  The problem here is
  18. that fcntl()'s FL_NONBLOCK flag applies to the open file description
  19. pointed to by a file descriptor.  Multiple processes can have file
  20. descriptors refeerring to the same open file description (e.g. the
  21. stdin of a program usually has the same OFD as the stdin of its
  22. shell), and when one process sets the file descriptor non-blocking,
  23. the other process suddenly starts getting EAGAINs from its read() and
  24. write() calls.
  25.  
  26. The only explanation for this, as far as I can tell, is that no one
  27. was paying attention when they standardized this in POSIX.  A simple
  28. solution is to add a second flag FD_NONBLOCK which applies only to the
  29. file descriptor.  read() and other blocking system calls will return
  30. EAGAIN if either the file descriptor or its corresponding open file
  31. description are set non-blocking.  This way, programs can set their
  32. file descriptors non-blocking without fear of sabotaging other
  33. processing using the same OFDs.
  34.  
  35. The issue is relevant to this list because if enough operating systems
  36. add FD_NONBLOCK, POSIX may take notice of it, standardize it, and
  37. possibly even deprecate FL_NONBLOCK.  Even if FD_NONBLOCK is never
  38. standardized, certain packages (for instance, Proven's threads
  39. library) can operate much more robustly with support for
  40. per-file-descriptor non-blocking flags.
  41.